package vn.anhqn.englishsentensetranslator.widget;
import vn.anhqn.englishsentensetranslator.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

public class HeverticalTextView extends TextView {

	public HeverticalTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.init(attrs);
	}

	public HeverticalTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		  this.init(attrs);
	}
	public HeverticalTextView(Context context) {
		super(context);
		  this.init(null);
	}
	
	
	private void init(AttributeSet attrs){
		this.initFontHelveticaNormal();
		if(attrs != null){
			TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.HeverticalTextView);
			final int count = ta.getIndexCount();
			for(int i = 0; i<count; i++){
				int attr = ta.getIndex(i);
				switch (attr) {
				case R.styleable.HeverticalTextView_textStyle:
					int type = ta.getInt(attr, 0);
					switch (type) {
					case 1://bold
						initFontHelveticaBold();
						break;
					case 2:// italic
						initFontHelveticaItalic();
						break;
					default:
						break;
					}
					break;
				default:
					break;
				}
			}
			ta.recycle();
		}
	}
	public void setTextStyle(int typeFace){
		
	}
	public  void initFontHelveticaNormal() {
            Context pContext = getContext();
        Typeface  typeface;
        typeface = Typeface.createFromAsset(pContext.getAssets(), "Helvetica/helvetica-normal.ttf"); 
        this.setTypeface(typeface);
    }
	
	public  void initFontHelveticaItalic() {
        Context pContext = getContext();
    Typeface  typeface;
    typeface = Typeface.createFromAsset(pContext.getAssets(), "Helvetica/helvetica-normal.ttf"); 
    this.setTypeface(typeface,Typeface.ITALIC);
	}
	
	public  void initFontHelveticaBold() {
        Context pContext = getContext();
    Typeface  typeface;
    typeface = Typeface.createFromAsset(pContext.getAssets(), "Helvetica/helvetica-normal.ttf"); 
    this.setTypeface(typeface,Typeface.BOLD);
    }   
}
